// import Empty from '@/components/Empty';
// import { Flex } from 'antd';
import { FC } from 'react';
import { useIntl } from 'umi';
import { InfoBlock } from '../components/InfoBlock';
import { InfoField } from '../components/InfoField';
import { useDict } from '../SelectedDeviceNodeContext';
interface IProps {
  data: API.LcRealTimeData;
}

export const Info: FC<IProps> = ({ data }) => {
  const { onlineState, chargeDischargeStatusOptions } = useDict();
  let OnlineStatusLabel = data?.onlineState;
  let chargeStatusLabel = data?.bmsState;

  if (onlineState && onlineState.length) {
    let arr = onlineState.filter((res) => String(res?.value) === String(data?.onlineState));
    if (arr.length > 0) {
      OnlineStatusLabel = arr[0]?.label;
    }
  }
  if (chargeDischargeStatusOptions && chargeDischargeStatusOptions.length) {
    let arr = chargeDischargeStatusOptions.filter(
      (res) => String(res?.value) === String(data?.bmsState),
    );
    if (arr.length > 0) {
      chargeStatusLabel = arr[0]?.label;
    }
  }
  const intl = useIntl();

  const Items = [
    {
      label: intl.formatMessage({ id: 'stationRealtimeMonitoring.chargeStatus' }),
      value: chargeStatusLabel,
    },
    {
      label: intl.formatMessage({ id: 'stationRealtimeMonitoring.onlineStatus' }),
      value: OnlineStatusLabel,
    },
    {
      label: intl.formatMessage({ id: 'stationRealtimeMonitoring.activePower' }),
      value: data?.activePower,
    },
    {
      label: intl.formatMessage({ id: 'stationRealtimeMonitoring.maxChargeStatus' }),
      value: data?.ableMaxChgPower,
      unit: 'kW',
    },
    {
      label: intl.formatMessage({ id: 'stationRealtimeMonitoring.maxDischargeStatus' }),
      value: data?.ableMaxDchgPower,
      unit: 'kW',
    },
  ];

  return (
    <div style={{ padding: '20px 30px', marginBottom: 0 }}>
      <InfoBlock title="">
        {Items.map((item, index) => (
          <InfoField key={index} label={item.label} value={item.value} unit={item?.unit} />
        ))}
      </InfoBlock>
    </div>
  );
};
